<template>
    <div class="acceptance-registration-pages">
        <commpVxeTable
         :config="dataTableConfig" 
         :columns="columnsVxe" 
         :formItem="formItem"
         @checkboxChange="checkboxChange"
         ref="acceptanceRegistrationRef"
         >
            <template v-slot:fsxmc_name="{row}" data-desc="自定操作栏">
                <span v-if="row.fzwxtbzzt == '补正中'" class="fsxmcQ-c-t">[{{ row.fzwxtbzzt}}]</span>
                <span v-if="row.fzwxtbzzt == '已补正'" class="fsxmcQ-l-t">[{{ row.fzwxtbzzt}}]</span>

                <span v-if="row.fzwxtzgzt == '整改中'" class="fsxmcQ-c-t">[{{ row.fzwxtzgzt }}]</span>
                <span v-if="row.fzwxtzgzt == '已整改'" class="fsxmcQ-l-t">[{{ row.fzwxtzgzt }}]</span>

                <span v-if="row.fzwxtcjzt == '撤件回复'" class="fsxmcQ-h-t" @click="cjhfClick()">[{{ row.fzwxtcjzt }}]</span>
                <span v-if="row.fzwxtcjzt == '撤件审核中'" class="fsxmcQ-c-t">[{{ row.fzwxtcjzt }}]</span>
                <span v-if="row.fzwxtcjzt == '已撤件'" class="fsxmcQ-l-t">[{{ row.fzwxtcjzt }}]</span>

                <span v-if="row.fzwxtthzt" class="fsxmcQ-h-t">{{ row.fzwxtthzt }}</span>
                <span>{{ row.fsxmc }}</span>
            </template>
            <template v-slot:name_fslsj="{row}" data-desc="自定操作栏">
                <span>{{ timeProcessing(row.fslsj) }}</span>
            </template>
            <template v-slot:operation_btn="{row}" data-desc="自定操作栏">
                <a-form layout="inline" class="search-form" >
                    <a-form-item >
                        <a-button class="blue-btn" type="primary" @click="reviseClick(row)">办理</a-button>
                    </a-form-item>
                </a-form>
            </template>
        </commpVxeTable>
        <increase
         ref="refModel" 
         :addEditParameter="addEditParameter" 
         :addEdittechnicalReview="addEdittechnicalReview" 
         @successReturn="successReturn"
         @reviseClick="reviseClick"
         />
    </div>
</template>
<script>
import {typeInput, typeNumber, typeSelect, typeCheckbox, typeRadio} from '@/components/compSearchCriteria/ContractType'
import assessCheckApi from './service/api.js'
import increase from './increase.vue'
import { deleteArrServe, ocalityPostAction, dateDataServe, duplicateServe, queryJobByJobIdServe } from './service/index'
import commpVxeTable from '@/components/commp-vxe-table/commp-vxe-table.vue'
import moment from 'moment'
import blobType from '@/common/blobType'
  export default {
    components:{
        increase,
        commpVxeTable
    },
    
    data(){
        return{
            addEditParameter:{},
            addEdittechnicalReview:{},
            formItem:[
                {
                    label: '事项名称',
                    model: 'fsxmc',
                },{
                    label: '企业名称',
                    model: 'fqymc',
                },{
                    label: '申请单号',
                    model: 'fsqdbh',
                },{
                    label: '任务编号',
                    model: 'fslbh',
                }

            ],
                // {
                //     label: '所在地市',
                //     model: 'fszds',
                //     placeholder: '所在地市',
                //     type:typeSelect,
                //     dictionaryType:'观察员所属地市',
                //     selectArr:this.dictionaryQuery('观察员所属地市')
                // }
            columnsVxe:[{ type: 'checkbox', width: 60 ,fixed: 'left',},{
                    title: '事项名称', //列头显示文字
                    field: 'fsxmc',
                slots: {
                    default: 'fsxmc_name',
                },
                    fixed: 'left',
                },{
                    title: '企业名称', //列头显示文字
                    field: 'fqymc',
                },{
                    title: '申请单号',
                    field: 'fsqdbh',
                },{
                    title: '任务编号',
                    field: 'fslbh',
                },{
                    title: '接收时间',
                    field: 'fslsj',
                    slots: {
                        // 使用插槽模板渲染
                        default: 'name_fslsj',
                    },
                },{
                    title: '剩余天数',
                    field: 'syday',
                },{
                    title: '操作',
                    field: 'jobid',
                    slots: {
                    // 使用插槽模板渲染
                    default: 'operation_btn',
                  },
                    fixed: 'right',
                    width:200,
                }],
            dataTableConfig:{
                api: assessCheckApi.list,
                rowId: 'jobid',
                fywflcode:blobType.fywflcodeArr[blobType.menuType.indexOf(this.$route.name.substring(this.$route.name.indexOf('__'),this.$route.name.indexOf('_a')+2))],
                paramet:{
                    fhjmc:this.$route.fullPath.indexOf('_$') !== -1?this.$route.fullPath.substring(this.$route.fullPath.indexOf('_a')+2,this.$route.fullPath.indexOf('_$')).split("_$").join(""):'技术审评',
                    fblzt:'待办'
                }
            },
            specifyDateVal:'',
            isSpecifyDate:false,
            currentReplicationId:'',
            selectedRowKeysArr:[],
        }
    },
    mounted(){
    },
    
    methods:{
        cjhfClick(){
            this.$route.push('/enterpriseWithdrawalApplication/index')
        },
        timeProcessing(val){
            if(val){
                val = val.slice(0,11)
            }
            return val
        },
        async dictionaryQuery(val){
            let dataObj = []
            await ocalityPostAction({dictName:val}).then(res=>{
                //console.log('字典的res',res)
                if(res.code == 200){
                    if(res.result.length){
                        dataObj = res.result
                    }
                    
                }
            })
            return dataObj
        },
        checkboxChange(val){//获取当前选择的行
            //console.log('当前选择表格',val)
            this.selectedRowKeysArr = []
            val.forEach(item => {
                this.selectedRowKeysArr.push(item.jobids)
            });
        },
        accessDateDataServe(val){
            //console.log('2',val)
            dateDataServe({time:val+" 00:00:00"}).then(res=>{
                if(res.code == 200){
                    this.$message.success('获取成功')
                    this.$refs.acceptanceRegistrationRef.searchEvent()
                }
            })
        },
        
        successReturn(){
            this.$refs.acceptanceRegistrationRef.searchEvent()
        },
        batchDeletion(){//
            var that = this
            this.$confirm({
                title:'您确认要删除吗？',
                // icon: createVNode(ExclamationCircleOutlined),
                onOk() {
                    if(that.selectedRowKeysArr.length){
                        let deleteString = that.selectedRowKeysArr.join(',')
                        deleteArrServe({ids:deleteString}).then(res=>{
                            if(res.code == 200){
                                that.$message.success('删除成功')
                            }else{
                                that.$message.warning(res.message)
                            }              
                            that.$refs.acceptanceRegistrationRef.searchEvent()
                        })
                    }else{
                        that.$message.warning('请选择删除项')
                    }
                },
                
            });
            
            
        },
        handleOk(val,id){
            if(val && !id){
                this.$refs.acceptanceRegistrationRef.resetEvent()
            }else if(val && id){
                this.requestParams = {
                    ...this.requestParams,
                    renovate:true,
                }
            }
            
        },
        //编辑
        reviseClick(val){
            queryJobByJobIdServe({jobid:val.jobid}).then(res=>{
                //console.log(res)
                if(res.code == 200){
                    let data = res.result.sqsx
                    this.addEditParameter = {
                        fhjmc:res.result.job.fhjmc,
                        fywflcode:blobType.fywflcodeArr[blobType.menuType.indexOf(this.$route.name.substring(this.$route.name.indexOf('__'),this.$route.name.indexOf('_a')+2))],
                        jobid:res.result.job.id,
                        sqsxid:data.id,
                        fsxmc:data.fsxmc,
                        fsqsj:data.fsqsj?moment(data.fsqsj).format('YYYY-MM-DD'):'',
                        fjclx:data.fjclx,
                        fslzt:String(data.fslzt),
                        fslsj:data.fslsj?moment(data.fslsj).format('YYYY-MM-DD'):'',
                        fslbh:data.fslbh,
                        fwcsx:data.fwcsx,
                        fjzrq:data.fjzrq,

                        fqyid:data.fqyid,//企业Id
                        fqymc:data.fqymc,
                        ftyshxydm:data.ftyshxydm,
                        fqyfddbrfzr:data.fqyfddbrfzr,
                        fqylxr:data.fqylxr,
                        fqylxrdh:data.fqylxrdh,
                        fqyzszcdz:data.fqyzszcdz,
                        fszdq:data.fszdq,
                        fxxdz:data.fxxdz,

                        fcpmc:data.fcpmc,//产品名称
                        fsqdbh:data.fsqdbh,
                        fspdwmc:data.fspdwmc,
                        fbldwmc:data.fbldwmc,
                        ffsr:data.ffsr,
                        ffssj:data.ffssj,
                        fblr:data.fblr,
                        dbrid:res.result.nextNodeDbrList.length == 1?[res.result.nextNodeDbrList[0].dbrid]:[],
                        opinion:'',//办理意见
                        smgflag:false,//是否发送短信
                        dbridRequired:true,
                        isReadOnly:true,
                        nextNodeDbrList:res.result.nextNodeDbrList,
                        nextNode:res.result.nextNode,

                        fcyjcyj:data.fcyjcyj,
                        fcyjcfw:data.fcyjcfw,
                        fcyptbm:data.fcyptbm,
                        fcyptry:data.fcyptry,
                        fcyptryzw:data.fcyptryzw,
                        fcyjg:data.fcyjg,
                        fcyyzqx:data.fcyyzqx,
                        fcyzyqx:data.fcyzyqx,
                        fcyybqx:data.fcyybqx,
                        fcyqtwt:data.fcyqtwt,
                        isHidden:false,


                        fzlgl:data.fzlgl,
                        fjgyry:data.fjgyry,
                        fcfyss:data.fcfyss,
                        fsb:data.fsb,
                        fwlycp:data.fwlycp,
                        fqryyz:data.fqryyz,
                        fwjqk:data.fwjqk,
                        fscgl:data.fscgl,
                        fzlkzybz:data.fzlkzybz,
                        fwtscyjy:data.fwtscyjy,
                        fcpfyyzh:data.fcpfyyzh,
                        fzj:data.fzj,
                        fcyjl:data.fcyjl,
                        reportInformation:'10',
                        reviewProjectTab:'审查项目',
                        fjcqkzs:data.fjcqkzs,
                        fsxjclx:data.fsxjclx,
                                ...res.result.qy,
                    }
                    this.addEdittechnicalReview = {
                        fhjmc:res.result.job.fhjmc,
                        fywflcode:blobType.fywflcodeArr[blobType.menuType.indexOf(this.$route.name.substring(this.$route.name.indexOf('__'),this.$route.name.indexOf('_a')+2))],
                        jobid:res.result.job.id,
                        sqsxid:data.id,
                        fsxmc:data.fsxmc,
                        fsqsj:data.fsqsj?moment(data.fsqsj).format('YYYY-MM-DD'):'',
                        fjclx:data.fjclx,
                        fslzt:String(data.fslzt),
                        fslsj:data.fslsj?moment(data.fslsj).format('YYYY-MM-DD'):'',
                        fslbh:data.fslbh,
                        fwcsx:data.fwcsx,
                        fjzrq:data.fjzrq,

                        fqyid:data.fqyid,//企业Id
                        fqymc:data.fqymc,
                        ftyshxydm:data.ftyshxydm,
                        fqyfddbrfzr:data.fqyfddbrfzr,
                        fqylxr:data.fqylxr,
                        fqylxrdh:data.fqylxrdh,
                        fqyzszcdz:data.fqyzszcdz,
                        fszdq:data.fszdq,
                        fxxdz:data.fxxdz,

                        fcpmc:data.fcpmc,//产品名称
                        fsqdbh:data.fsqdbh,
                        fspdwmc:data.fspdwmc,
                        fbldwmc:data.fbldwmc,
                        ffsr:data.ffsr,
                        ffssj:data.ffssj,
                        fblr:data.fblr,
                        dbrid:res.result.nextNodeDbrList.length == 1?[res.result.nextNodeDbrList[0].dbrid]:[],
                        opinion:'',//办理意见
                        smgflag:false,//是否发送短信
                        dbridRequired:true,
                        isReadOnly:true,
                        nextNodeDbrList:res.result.nextNodeDbrList,
                        nextNode:res.result.nextNode,

                        fspyj:data.fspyj,
                        // fcyptbm:data.fcyptbm,
                        // fcyptry:data.fcyptry,
                        // fcyptryzw:data.fcyptryzw,
                        fspjg:data.fspjg,
                        fspyzqx:data.fspyzqx,
                        fspzyqx:data.fspzyqx,
                        fspybqx:data.fspybqx,
                        fspqtwt:data.fspqtwt,
                        isHidden:false,

                        fzlgl:data.fzlgl,
                        fjgyry:data.fjgyry,
                        fcfyss:data.fcfyss,
                        fsb:data.fsb,
                        fwlycp:data.fwlycp,
                        fqryyz:data.fqryyz,
                        fwjqk:data.fwjqk,
                        fscgl:data.fscgl,
                        fzlkzybz:data.fzlkzybz,
                        fwtscyjy:data.fwtscyjy,
                        fcpfyyzh:data.fcpfyyzh,
                        fzj:data.fzj,
                        fcyjl:data.fcyjl,
                        reportInformation:'10',
                        reviewProjectTab:'审查项目',
                        fjcqkzs:data.fjcqkzs,
                        fsxjclx:data.fsxjclx,
                                ...res.result.qy,
                    }
                    this.$refs.refModel.getData(this.addEditParameter)
                    this.$refs.refModel.visibleShow = true
                }else{
                    this.$message.warning(res.message)
                }
            })
            
            
        },
        
        AddHandleOk(){
            this.$refs.acceptanceRegistrationRef.resetEvent()
        }
    },

  }
</script>
<style lang="less">
.acceptance-registration-pages{
    .select-date-box{
        display: flex;
        flex-direction: column;
        span{
            color: #f5222d;
            font-size: 14px;
        }
    }
    .modal-btn-box{
        .ant-form-item-control{
            width: 175px !important;
        }
    }
    
}
</style>
<style scoped >
.observer-lbrary-pages{
    background: #fff;
}
.btn-box{
    display: flex;
    justify-content: flex-end;
}
.blue-btn{
    border: 1px solid #5ca3e5 !important;
    background-color: #5ca3e5 !important;
    color: #fff !important;
}
.red-btn{
    border: 1px solid #ed5565 !important;
    background-color: #ed5565 !important;
}




</style>